import { _decorator, Camera, Component, Node } from 'cc';
import { EventListener } from '../core/EventListener';
import { Constants, Orientation } from './Constants';
import { UIManager } from '../gui/UIManager';
const { ccclass, property } = _decorator;

@ccclass('Camere3DManager')
export class Camere3DManager extends Component {
    private camera: Camera = null;

    start() {
        this.camera = this.getComponent(Camera)!;
        EventListener.on(Constants.Event_OrientationChange, this.onOrientationChange, this);
        this.onOrientationChange();
    }

    private onOrientationChange() {
        if(UIManager.Instance.orientation === Orientation.Landscape) {
            this.camera.orthoHeight = 400;
        } else {
            this.camera.orthoHeight = 640;
        }
    }
}